<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>新增客户</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link id="bootstrap-style" href="<c:url value="/css/bootstrap.min.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/bootstrap-responsive.min.css"/>" rel="stylesheet">
	<link id="base-style" href="<c:url value="/css/style.css"/>" rel="stylesheet">
	<link id="base-style-responsive" href="<c:url value="/css/style-responsive.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/index.css"/>" rel="stylesheet">
	<link rel="shortcut icon" href="<c:url value="/img/favicon.ico"/>">
	<link href="<c:url value="/css/page.css"/>" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/jquery.datetimepicker.css"/>"/>
	<link href="<c:url value="/css/navuser.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/but.css"/>" rel="stylesheet">
	<script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script>
	<script src="<c:url value="/js/jquery-migrate-1.0.0.min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/js/layer/layer.js"/>"></script>
	<script src="<c:url value="/js/laydate/laydate.js"/>"></script>
	<script src="<c:url value="/js/build/jquery.datetimepicker.full.js"/>"></script>
	<script src="<c:url value="/js/orgin.js"/>"></script>
	<script src="<c:url value="/js/filebut.js"/>"></script>
</head>
 <script type="text/javascript">
 function save(){
	 var title = $("#title").val();
	 var introduction = $("#introduction").val();
	 var summary = $("#summary").val();
	 if(title == null || title == ""){
		 alert("请输入标题！");
		 return;
	 }
	 if(introduction == null || introduction == ""){
		 alert("请输入摘要！");
		 return;
	 }
	 if(summary == null || summary == ""){
		 alert("请输入内容！");
		 return;
	 }
	 beyondsummary();
	 $("#customerform").submit();
 }
 
 $(function(){ 
	 var msg="${msg}";
	 if(msg!=null&&msg!=""){
		 alert(msg);
         closebutton();
         window.parent.location.reload(); //刷新父页面
		 /* window.parent.location.reload(); //刷新父页面
		 var index = parent.layer.getFrameIndex(window.name);  
		 parent.layer.close(index);  
		 alert(msg); */
	 }
 }); 
 
 //返回
 function reback(){
     var url='<%=basePath%>message/mainpage';
     parent.$("#mainFrame").attr("src",url);
 }
 
 //取消
 function closebutton() {
		var index = parent.layer.getFrameIndex(window.name);  
	 	parent.layer.close(index);  
}
 
 function beyond(){
	 var outline = $("#introduction").val();
	 var showText = document.getElementById("introduction");
	 if(outline.length > 30){
		 showText.style.color = "red";
		 alert("摘要超出最大输入字数30！！！")
		 return;
	 }else{
	 	showText.style.color = "black";
	 }
 }
 function beyondsummary(){
	 var outline = $("#summary").val();
	 var showText = document.getElementById("summary");
	 if(outline.length > 500){
		 showText.style.color = "red";
		 alert("内容超出最大输入字数500！！！")
		 return;
	 }else{
	 	showText.style.color = "black";
	 }
 }
</script>
<body>
<div id="content" class="span10" style="background-color:#F9F9F9;">
<div style="background-color:#FFF">
<form name="customerform" id="customerform" method="post" enctype="multipart/form-data" action="<%=basePath%>message/save">
	<input type="hidden" name="id" value="${customerid }">
	<table>
			<tr>
				<td>标题：<font color="red">*</font></td>
				<td><input type="text" id="title" name="title" value="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
				<td>作者：</td>
				<td><input type="text" id="author" name="author" value=""></td>
			</tr>
			<tr>
				<td>内容类型：</td>
				<td>
					<select name="contenttypeid" id="contenttypeid" class="buildselect">
						<option value="">请选择</option>
						<c:forEach items="${contentlist }" var="a">
							<option value="${a.id }"  ${a.id==contenttypeid?'selected':''}>${a.name }</option>
						</c:forEach> 
					</select>
				</td>
				<td>出处：</td>
				<td><input type="text" id="source" name="source" value=""></td>
			</tr>
			<tr>
				<td>摘要：<font color="red">*</font></td>
				<td colspan = "3"><input style="width: 100%;" onkeyup="beyond();" type="text" id="introduction" name="introduction" value=""></td>
			</tr>
			<tr>
				<td>链接：</td>
				<td colspan = "3"><input style="width: 100%;" type="text" id="linkaddress" name="linkaddress" value=""></td>
			</tr>
			<tr style="display:none">
				<td>有效起始时间：</td>
				<td>
					<input type="date" id="starttime" name="starttime" style="width:40%;">
				</td>
				<td>有效结束时间：</td>
				<td>
					<input type="date" id="endtime" name="endtime" style="width:40%;">
				</td>
			</tr>
			<tr>
				<td>内容：<font color="red">*</font></td>
				<td colspan = "3">
					<textarea style="width: 100%;" onkeyup="beyondsummary();" rows="6" cols="" id="summary" name="summary"></textarea>
				</td>
			</tr>
	</table>
</form>
<div class="row-fluid content-table">
<table class="table  bootstrap-datatable" style=" border:none; border-spacing:0; border-collapse:collapse;margin:0;padding:0;">
	<tbody>
		<tr class="content-search" style="text-align: center;">
			<td colspan="6">
				<div>
					<button style="background-color: #dadada;color: #666;" type="button" onclick="closebutton();" id="output1">取消</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<button class="but" onclick="save();">提交</button>
				</div>
			</td>
		</tr>
	</tbody>
</table>            
</div>

</div>
</div>	
</body>
</html>
